package com.sos.data.filters
{
	import com.sos.utils.StringUtils;
	
	public class StringFilter extends DataFilter
	{
		
		// -------------------------------------------------------------------------------
		// FIELDS
		// -------------------------------------------------------------------------------

		// -------------------------------------------------------------------------------
		// CONSTRUCTOR
		// -------------------------------------------------------------------------------	
		
		public function StringFilter(name:String, field:String, value:Object):void
		{
			super(name, field, value);
		}
		
		// -------------------------------------------------------------------------------
		// PUBLIC METHODS
		// -------------------------------------------------------------------------------
		
		/**
		 * Evaluate the filter using the given object 
		 * @param obj Object to evaluate with the filter
		 * @return True if the given object is not null, has a the 'field' and the 'field' is
		 * strict equal to 'value'
		 */		
		override public function evaluate(obj:Object):Boolean
		{
			return 	obj != null &&
					obj.hasOwnProperty(_field) &&
					StringUtils.startWith(obj[_field], _value.toString());
		}
		
	}
}